package com.dineroquegastar.urule.controller;

import com.dineroquegastar.urule.accident.entity.Customer;
import com.dineroquegastar.urule.entity.feature.mexico.FeaturesCalculationRequest;
import com.dineroquegastar.urule.entity.feature.product.FeaturesProductGradeRequest;
import com.dineroquegastar.urule.service.LoanResultLevelService;
import com.dineroquegastar.urule.service.RiskEyeService;
import com.dineroquegastar.urule.utils.jackson.JsonJacksonUtil;
import com.dineroquegastar.urule.vo.QueryLoanResultLevelParamVO;
import com.dineroquegastar.urule.vo.ResponseVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Map;

/**
 * 墨西哥决策引擎计算接口
 *
 * @author liuhai
 * @date 2021/3/1 5:15 PM
 */
@RestController
@RequestMapping(value = "/uruleapi/v1")
@Slf4j
public class MexicoUruleController {

    @Autowired
    private LoanResultLevelService loanResultLevelService;
    @Autowired
    private RiskEyeService riskEyeService;

    /**
     * 决策客户贷款级别
     *
     * @param paramVO
     * @return
     */
    @RequestMapping(value = "/loanResultLevel", method = RequestMethod.POST)
    public ResponseVo loanResultLevel(@RequestBody FeaturesProductGradeRequest paramVO) {
        //log.info("loanResultLevel param:{}", JsonJacksonUtil.toJson(paramVO));

        return ResponseVo.success(loanResultLevelService.loanResultLevel(paramVO));
    }


    /**
     * 风控眼接口
     * <p>
     * 根据传入的特征值计算风控决策结果
     *
     * @param paramVO
     * @return
     */
    @RequestMapping(value = "/riskEye", method = RequestMethod.POST)
    public ResponseVo riskEye(@RequestBody FeaturesCalculationRequest paramVO) {
        log.info("riskEye param:{}", JsonJacksonUtil.toJson(paramVO));

        return ResponseVo.success(riskEyeService.riskEyeResult(paramVO));
    }

}
